package com.dona.imsidetector.db.entity;

import com.dona.imsidetector.bean.vo.ListItemVo;
import com.dona.imsidetector.utils.DeviceUtil;
import com.dona.imsidetector.utils.IMSIUtil;

import org.xutils.db.annotation.Column;
import org.xutils.db.annotation.Table;

import java.util.Date;

// 黑白名单项
@Table(name ="imsiitem")
public class ListItem {

    @Column(name="uuid", isId = true)
    private String uuid;

    @Column(name = "listId")
    private String listId;

    // 是否是白名单，1表示是，0表示黑名单
    @Column(name = "isWhite")
    private int isWhite;

    // 运营商 1表示移动， 2表示联通 3表示电信 4表示其他
    @Column(name = "isp")
    private int isp;

    // imsi
    @Column(name= "imsiAddr")
    private String imsiAddr;

    @Column(name="province")
    private String province; // 运营商所在的省

    @Column(name="city")
    private String city; // 运营商所在的省的市

    @Column(name="createTime")
    private Date createTime;

    public ListItem(){

    }

    public ListItem(String listId, int isWhite, String imsiAddr){
        this.uuid = DeviceUtil.getUUID();
        this.listId = listId;
        this.isWhite = isWhite;
        this.imsiAddr = imsiAddr;
        this.isp = IMSIUtil.checkImsiType(imsiAddr);
        this.createTime = new Date();
    }

    public ListItem(ListItemVo listItemVo){
        this.uuid = listItemVo.getUuid();
        this.listId = listItemVo.getListid();
        this.isWhite = listItemVo.getIsWhite();
        this.imsiAddr = listItemVo.getImsiaddr();
        this.isp = listItemVo.getIsp();
        this.province = listItemVo.getProvince();
        this.city = listItemVo.getCity();
        this.createTime = listItemVo.getCreateTime();
    }


    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getListId() {
        return listId;
    }

    public void setListId(String listId) {
        this.listId = listId;
    }

    public int getIsWhite() {
        return isWhite;
    }

    public void setIsWhite(int isWhite) {
        this.isWhite = isWhite;
    }

    public int getIsp() {
        return isp;
    }

    public String getIspDesc() {
        switch (isp){
            case 1:
                return "移动";
            case 2:
                return "联通";
            case 3:
                return "电信";
            default:
                return "其它";
        }
    }

    public void setIsp(int isp) {
        this.isp = isp;
    }

    public String getImsiAddr() {
        return imsiAddr;
    }

    public void setImsiAddr(String imsiAddr) {
        this.imsiAddr = imsiAddr;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }


    @Override
    public String toString() {
        return "ListItem{" +
                "uuid='" + uuid + '\'' +
                ", listId='" + listId + '\'' +
                ", isWhite=" + isWhite +
                ", isp=" + isp +
                ", imsiAddr='" + imsiAddr + '\'' +
                ", province='" + province + '\'' +
                ", city='" + city + '\'' +
                ", createTime=" + createTime +
                '}';
    }
}
